# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=glade
pkgver=3.40.0
pkgrel=6
pkgdesc="User Interface Designer for GTK+ and GNOME"
url="https://glade.gnome.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	gobject-introspection-dev
	gtk+3.0-dev
	gtk-doc
	itstool
	libxml2-dev
	meson
	py3-gobject3-dev
	python3-dev
	webkit2gtk-4.1-dev
	"
checkdepends="
	adwaita-icon-theme
	dbus
	ibus
	xvfb-run
	"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
source="https://download.gnome.org/sources/glade/${pkgver%.*}/glade-$pkgver.tar.xz
	webkit2gtk-4.1.patch
	"
# XXX: segfault in mozjs102, but it runs fine..
options="!check"

case "$CARCH" in
armhf|s390x|riscv64)
	;;
*)
	makedepends="$makedepends gjs-dev"
	;;
esac

if [ "$CARCH" = "s390x" ]; then
	# no adwaita-icon-theme
	options="$options !check"
fi

build() {
	abuild-meson \
		-Dgladeui=true \
		. output
	meson compile -C output
}

check() {
	XDG_RUNTIME_DIR="$(mktemp -d -p "$builddir")" \
	dbus-run-session -- \
		xvfb-run -a \
		meson test -t 6 --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

dev() {
	default_dev

	mkdir -p "$pkgdir"/usr/share/glade
	mv "$subpkgdir"/usr/share/glade/catalogs "$pkgdir"/usr/share/glade
	mv "$subpkgdir"/usr/lib/glade "$pkgdir"/usr/lib/glade
}

sha512sums="
6b018f882e9d155a4b2256c0b4c72743f971c8d730a53f16faa240d01e14051f5b6ce04e355dcc78e1679579fb091facaa06acdda6297c5b8efc642c42bb7b4e  glade-3.40.0.tar.xz
9ce098990c38cf2c9b2b0ec98d3e0925ebf5d2b993240f5ae2a0a4f2c3f027625a32d694f8626f7ede693caa60ecd55abd75e93e0cb60fe0bd0637ae170f85d9  webkit2gtk-4.1.patch
"
